﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.BLL;
using KPIS.GERP.GIMS.IBLL;
using KPIS.GERP.GIMS.MODEL;
using System.Data;
using System.IO;

namespace KPIS.GERP.GIMS.APP.APP_UI.Edit_Form
{
    public partial class ICM_Purchase_Request_Urgent : System.Web.UI.Page
    {
        Common.Main cn = new Common.Main();
        CommandControl cmdFac = new CommandControl();
        PurchaseRequestBLL bllPrReq = new PurchaseRequestBLL();
        IBLLMasterPurchaseMethod bllMasPcMethod = new MasterPurchaseMethodBLL();
        PurchaseRequestItemBLL bllPcReqItem = new PurchaseRequestItemBLL();
        double totalPrice = 0;
        int nCount = 0;
        IBLLDocument bllPprFile = new DocumentBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //LoadPurchaseMethod();
                GetKeyValue();
                TipConfirm.TargetControls.Add(Forward.ClientID, true);
                TipHistory.TargetControls.Add(History_File.ClientID, "1", true);

                int seq = GetSeq();
                Button TmpBtn = (Button)RadPanelBar1.FindItemByValue("Bar1").FindControl("btnHistoryApprove");
                TipHistoryApprove.TargetControls.Add(TmpBtn.ClientID, "HisApprove:" + seq, true);

                TmpBtn = (Button)RadPanelBar1.FindItemByValue("Bar1").FindControl("btnHistoryInform");
                TipHistoryInform.TargetControls.Add(TmpBtn.ClientID, "HisInform:" + seq, true);
            }
        }

        protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
        {
            if (RadTabStrip1.SelectedTab.Value == "Detail")
            {
                GetKeyValue();
            }
            else if (RadTabStrip1.SelectedTab.Value == "Item")
            {
                LoadGridItem();
            }
            else if (RadTabStrip1.SelectedTab.Value == "File")
            {
                LoadGridFile();
            }
            else if (RadTabStrip1.SelectedTab.Value == "Report")
            {
                LoadGrid_Report();
            }
            else if (RadTabStrip1.SelectedTab.Value == "Progress")
            {
                LoadGridApprove();
                LoadGridInform();
                LoadGridRequest();
                LoadGridPublishing();
            }
        }

        protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip(args.Value, args.UpdatePanel);
        }

        private void UpdateToolTip(string elementID, UpdatePanel panel)
        {
            Control ctrl = Page.LoadControl("../UserControl/TIP_Purchase_Request_Confirm_Urgent.ascx");
            ((KPIS.GERP.GIMS.APP.APP_UI.UserControl.TIP_Purchase_Request_Confirm_Urgent)ctrl).RefreshParentDisplay = new CallBackHandle(RefreshDisplay);
            ((KPIS.GERP.GIMS.APP.APP_UI.UserControl.TIP_Purchase_Request_Confirm_Urgent)ctrl).GetPrSeq = new CallBackHandleReturnInt(GetSeq);
            ((KPIS.GERP.GIMS.APP.APP_UI.UserControl.TIP_Purchase_Request_Confirm_Urgent)ctrl).Alert = new CallBackHandleAlert(Alert);
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }
        
        protected void RefreshDisplay()
        {
            RadManager1.ResponseScripts.Add(@"CloseActiveToolTip();");
            GetKeyValue();
        }

        protected void Alert()
        {
            RadManager1.Alert(Session["Alert"].ToString());
        }

        protected void Reject_Click(object sender, EventArgs e)
        {
            try
            {
                int seq = GetSeq();
                bllPrReq.UpdatePurchaseRequestStatus(seq, SystemInfo._CancelRecordStatus);
                RadManager1.Alert(SystemInfo._ConfirmComplete);
                GetKeyValue();
            }
            catch
            {
                RadManager1.Alert(SystemInfo._CancelError);
            }
        }

        protected void ManageDisplay(string Status)
        {
            switch (Status)
            {
                case "A": //อนุมัติแล้ว
                case "P": //รอการอนุมัติ
                    // tab ข้อมูลหลัก
                    panelCommand_Detail.Visible = false;
                    // tab เอกสารแนบ
                    panelCommand_File.Visible = false;
                    Forward.Visible = false;
                    Reject.Visible = true;
                    break;
                case "C": //ยกเลิก
                    // tab ข้อมูลหลัก
                    panelCommand_Detail.Visible = false;
                    // tab เอกสารแนบ
                    panelCommand_File.Visible = false;
                    Forward.Visible = false;
                    Reject.Visible = false;
                    break;
                case "N": //ไม่ผ่านการอนุมัติ
                case "R": //ตีกลับ
                case "W": //รอการยืนยัน
                    // tab ข้อมูลหลัก
                    panelCommand_Detail.Visible = true;
                    // tab เอกสารแนบ
                    panelCommand_File.Visible = true;
                    Forward.Visible = true;
                    Reject.Visible = false;
                    break;
            }
        }

        protected int GetSeq()
        {
            int seq = Convert.ToInt32(Request.QueryString["Seq"]);
            return seq;
        }

        //-----------------------------------------------------------------------------------------------

        #region tab ข้อมูลหลัก

        //protected void LoadPurchaseMethod()
        //{
        //    int seq = GetSeq();
        //    IList<MasterPurchaseMethodInfo> infoPprMethod = bllMasPcMethod.GetMasterPurchaseMethodByPrSeq(seq);
        //    cbPurchaseMethod.DataSource = infoPprMethod;
        //    cbPurchaseMethod.DataBind();
        //}

        protected void cbPurchaseMethod_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            int seq = GetSeq();
            IList<MasterPurchaseMethodInfo> infoList = bllMasPcMethod.GetMasterPurchaseMethodByPrSeq(seq);
            for (int i = 0; i < infoList.Count; i++)
            {
                cbPurchaseMethod.Items.Add(new RadComboBoxItem(infoList[i].Name, infoList[i].Seq.ToString() + ":" + infoList[i].Bidding_status + ":" + infoList[i].Descr));
            }
            cbPurchaseMethod.DataBind();
        }

        public void GetKeyValue()
        {
            PurchaseRequestInfo infoPrReq = new PurchaseRequestInfo();
            int seq = GetSeq();
            infoPrReq = bllPrReq.GetPurchaseRequestUrgent(seq);
            lblYearType.Text = infoPrReq.InfoYearType.Name;
            lblYear.Text = infoPrReq.BgmYear.ToString();
            lblPurchaseRule.Text = infoPrReq.InfoPurchaseRule.Name;
            lblPurchaseType.Text = infoPrReq.InfoPurchaseType.Name;
            lblDate.Text = ((DateTime)infoPrReq.PurchaseDate).ToString("dd/MM/yyyy");
            lblName.Text = infoPrReq.Name;
            lblReason.Text = infoPrReq.Reason;
            lblPurchaseMethod.Text = infoPrReq.InfoPurchaseMethod.Name;
            lblPurchaseMethodReason.Text = infoPrReq.MethodReason;
            lblStatus.Text = infoPrReq.InfoRecordStatus.Name;
            lblProgress.Text = infoPrReq.InfoProgress.Name;

            lblPurchaseMethod.Visible = true;
            lblPurchaseMethodReason.Visible = true;
            cbPurchaseMethod.Visible = false;
            lblWarningPcMethod.Visible = false;
            txtPurchaseMethodReason.Visible = false;
            lblWarningPcMethodReason.Visible = false;

            Edit_Detail.Visible = true;
            EditSave_Detail.Visible = false;
            Cancel_Detail.Visible = false;

            cbPurchaseMethod.Text = infoPrReq.InfoPurchaseMethod.Name;
            cbPurchaseMethod.SelectedValue = infoPrReq.InfoPurchaseMethod.Seq.ToString();
            txtPurchaseMethodReason.Text = infoPrReq.MethodReason;

            if (infoPrReq.InfoPurchaseMethod.Seq == null)
            {
                panelWarning.Visible = true;
                panelHidden.Visible = false;
            }
            else
            {
                panelWarning.Visible = false;
                panelHidden.Visible = true;
            }

            ManageDisplay(infoPrReq.InfoRecordStatus.Status);
        }

        protected void Edit_Detail_Click(object sender, EventArgs e)
        {
            Edit_Detail.Visible = false;
            EditSave_Detail.Visible = true;
            Cancel_Detail.Visible = true;

            lblPurchaseMethod.Visible = false;
            lblPurchaseMethodReason.Visible = false;
            cbPurchaseMethod.Visible = true;
            lblWarningPcMethod.Visible = true;
            txtPurchaseMethodReason.Visible = true;
            lblWarningPcMethodReason.Visible = true;
            LoadValiDateDetail();
        }

        protected void EditSave_Detail_Click(object sender, EventArgs e)
        {
            try
            {
                int seq = GetSeq();
                string[] all_value = cbPurchaseMethod.SelectedValue.Split(':');
                bllPrReq.UpdatePurchaseMethod(seq, Convert.ToInt32(all_value[0]), txtPurchaseMethodReason.Text);
            }
            catch
            {
                RadManager1.Alert(SystemInfo._InsertError);
                return;
            }
            GetKeyValue();
        }

        protected void Cancel_Detail_Click(object sender, EventArgs e)
        {
            GetKeyValue();
        }

        protected void btnEditPcMethod_Click(object sender, EventArgs e)
        {
            RadTabStrip1.SelectedIndex = 0;
            RadPageView1.Selected = true;
            Edit_Detail_Click(null, null);
        }

        private void LoadValiDateDetail()
        {
            RequiredFieldValidator valcbPurchaseMethod = new RequiredFieldValidator();
            valcbPurchaseMethod.ID = "ValcbPurchaseMethod";
            valcbPurchaseMethod.ControlToValidate = "cbPurchaseMethod";
            valcbPurchaseMethod.SetFocusOnError = true;
            valcbPurchaseMethod.Display = ValidatorDisplay.Dynamic;
            valcbPurchaseMethod.ErrorMessage = "* กรุณาระบุวิธีการจัดหา *";
            panelValcbPurchaseMethod.Controls.Add(valcbPurchaseMethod);
            RequiredFieldValidator valPurchaseMethodReason = new RequiredFieldValidator();
            valPurchaseMethodReason.ID = "ValtxtPurchaseMethodReason";
            valPurchaseMethodReason.ControlToValidate = "txtPurchaseMethodReason";
            valPurchaseMethodReason.SetFocusOnError = true;
            valPurchaseMethodReason.Display = ValidatorDisplay.Dynamic;
            valPurchaseMethodReason.ErrorMessage = "* กรุณาระบุเหตุผลที่เลือกใช้วิธีการ *";
            panelValPurchaseMethodReason.Controls.Add(valPurchaseMethodReason);
        }


        #endregion

        //-----------------------------------------------------------------------------------------------

        #region tab รายการพัสดุ

        protected void LoadGridItem()
        {
            int seq = GetSeq();
            IList<PurchaseRequestItemInfo> infoPcReqItem = bllPcReqItem.GetPurchaseRequestItem(seq);
            Grid_Item.DataSource = infoPcReqItem;
            GridGroupByExpression geExpense = new GridGroupByExpression(Grid_Item.Columns[0]);
            Grid_Item.MasterTableView.GroupByExpressions.Add(geExpense);

            Grid_Item.DataBind();
        }

        protected void Grid_Item_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridItem();
        }

        protected void Grid_Item_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (nCount == 0)
            {
                totalPrice = 0;
            }
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                nCount++;
                double qty = 0;
                double price = 0;
                GridDataItem dataBoundItem = e.Item as GridDataItem;

                if (dataBoundItem["Qty"].Text.Length > 0)
                {
                    qty = double.Parse(dataBoundItem["Qty"].Text);
                }
                if (((Label)(dataBoundItem["Price"].FindControl("lblPrice"))).Text.Length > 0)
                {
                    price = double.Parse(((Label)(dataBoundItem["Price"].FindControl("lblPrice"))).Text);
                }

                totalPrice += (qty * price);
            }
            else if (e.Item is GridFooterItem)
            {
                GridFooterItem footer = (GridFooterItem)e.Item;
                footer["Descr"].Controls.Add(new LiteralControl("<div align='right' style='color: Black; font-weight: bold;'>วงเงินจัดหาทั้งหมด :</div> "));
                ((Label)footer["Price"].FindControl("lblTotalPrice")).Text = totalPrice.ToString("###,###,##0.00");
                nCount = 0;
            }
        }

        #endregion

        //-----------------------------------------------------------------------------------------------

        #region tab เอกสารแนบ

        protected void LoadGridFile()
        {
            int seq = GetSeq();
            Grid_File.DataSource = bllPprFile.GetDocument(seq, "icm_purchase_request_file", "ICM_PR_SEQ", "icm_pr_file_seq");
            Grid_File.DataBind();

            cmdFac.GridCommand(panelList_File, panelGrid_File, panelCommand_File);
        }

        protected void Grid_File_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridFile();
        }

        protected void AddNew_File_Click(object sender, EventArgs e)
        {
            RequiredFieldValidator valFileName = new RequiredFieldValidator();
            valFileName.ID = "ValtxtFileName";
            valFileName.ControlToValidate = "txtFileName";
            valFileName.SetFocusOnError = true;
            valFileName.Display = ValidatorDisplay.Dynamic;
            valFileName.ErrorMessage = "* กรุณาระบุชื่อไฟล์ *";
            panelValtxtFileName.Controls.Add(valFileName);
            RequiredFieldValidator valAttachment = new RequiredFieldValidator();
            valAttachment.ID = "Valattachment";
            valAttachment.ControlToValidate = "attachment";
            valAttachment.SetFocusOnError = true;
            valAttachment.Display = ValidatorDisplay.Dynamic;
            valAttachment.ErrorMessage = "* กรุณาระบุที่อยู่ไฟล์ *";
            panelValattachment.Controls.Add(valAttachment);
            cmdFac.AddNewCommand(panelList_File, panelGrid_File, panelCommand_File);
        }

        protected void AddNewSave_File_Click(object sender, EventArgs e)
        {
            int seq = GetSeq();
            FileInfo infoFile = new FileInfo(hdSourceFile.Value);
            DocumentInfo info = new DocumentInfo();
            RecordInfo infoRecord = new RecordInfo();
            infoRecord.Created_by = cn.UserID;
            infoRecord.Created_when = DateTime.Now;
            info.File_info = infoFile;
            info.Name = txtFileName.Text;
            info.Dest_path = hdSourceFile.Value;
            info.InfoRecord = infoRecord;

            try
            {
                bllPprFile.InsertFileToDB(info, "ICM_PURCHASE_REQUEST_FILE", "ICM_PR_SEQ", seq);
                LoadGridFile();
            }
            catch
            {
                RadManager1.Alert(SystemInfo._InsertError);
                return;
            }
        }

        protected void Delete_File_Click(object sender, EventArgs e)
        {
            IList<DocumentInfo> infoList = new List<DocumentInfo>();
            foreach (GridDataItem data in Grid_File.MasterTableView.GetSelectedItems())
            {
                DocumentInfo info = new DocumentInfo();
                RecordInfo infoRecord = new RecordInfo();
                info.Seq = Convert.ToInt32(data.OwnerTableView.DataKeyValues[data.ItemIndex]["Seq"]);
                infoRecord.Updated_by = Int32.Parse(Session["EmpSeq"].ToString());
                infoRecord.Updated_when = DateTime.Now;
                info.InfoRecord = infoRecord;
                infoList.Add(info);
            }

            if (infoList.Count == 0)
            {
                RadManager1.Alert(SystemInfo._DeleteNull);
                return;
            }

            try
            {
                bllPprFile.DeleteFileFromDB(infoList, "ICM_PURCHASE_REQUEST_FILE", "ICM_PR_FILE_SEQ");
            }
            catch
            {
                RadManager1.Alert(SystemInfo._DeleteError);
                return;
            }

            LoadGridFile();
        }

        protected void ShowGrid_File_Click(object sender, EventArgs e)
        {
            LoadGridFile();
        }

        protected void OnAjaxUpdate_History(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip_History(args.Value, args.UpdatePanel);
        }

        private void UpdateToolTip_History(string elementID, UpdatePanel panel)
        {
            int seq = GetSeq();
            Session["PrSeq"] = seq;
            Control ctrl = Page.LoadControl("../UserControl/TIP_Purchase_Request_File_History.ascx");
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }

        #endregion

        //-----------------------------------------------------------------------------------------------

        #region tab ข้อมูลรายงาน

        protected void LoadGrid_Report()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Seq", typeof(int));
            dt.Columns.Add("ReportName", typeof(string));
            dt.Rows.Add(0, "รายงาน 1");
            dt.Rows.Add(1, "รายงาน 2");
            Grid_Report.DataSource = dt;
            Grid_Report.DataBind();
        }

        protected void Grid_Report_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGrid_Report();
        }

        #endregion

        //-----------------------------------------------------------------------------------------------

        #region tab ข้อมูลการความคืบหน้า

        ProgressPurchaseRequestBLL bllPr = new ProgressPurchaseRequestBLL();

        protected void LoadGridApprove()
        {
            int seq = GetSeq();
            IList<PurchaseRequestRouteInfo> InfoPrRouteList = bllPr.GetPurchaseRequestApprove(seq);
            RadGrid TmpGrid = (RadGrid)RadPanelBar1.FindItemByValue("Bar1").FindControl("GridApprove");
            TmpGrid.DataSource = InfoPrRouteList;
            TmpGrid.DataBind();
        }

        protected void LoadGridInform()
        {
            int seq = GetSeq();
            IList<PurchaseRequestRouteInfo> InfoPrRouteList = bllPr.GetPurchaseRequestInform(seq);
            RadGrid TmpGrid2 = (RadGrid)RadPanelBar1.FindItemByValue("Bar1").FindControl("GridInform");
            GridGroupByExpression g;
            TmpGrid2.DataSource = InfoPrRouteList;
            TmpGrid2.MasterTableView.GroupByExpressions.Clear();
            g = new GridGroupByExpression(TmpGrid2.Columns[0]);
            TmpGrid2.MasterTableView.GroupByExpressions.Add(g);

            TmpGrid2.Columns[0].Visible = false;
            TmpGrid2.DataBind();
        }

        protected void LoadGridRequest()
        {
            int seq = GetSeq();
            IList<PurchaseRequestInfo> InfoPr = bllPr.GetPurchaseRequest(seq);
            RadGrid TmpGrid = (RadGrid)RadPanelBar1.FindItemByValue("Bar2").FindControl("GridRequest");
            TmpGrid.DataSource = InfoPr;
            TmpGrid.DataBind();
        }

        protected void LoadGridPublishing()
        {
            int seq = GetSeq();
            IList<BidInfo> InfoBid = bllPr.GetBid(seq);
            RadGrid TmpGrid = (RadGrid)RadPanelBar1.FindItemByValue("Bar3").FindControl("GridPublishing");
            TmpGrid.DataSource = InfoBid;
            TmpGrid.DataBind();
        }

        protected void GridApprove_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridApprove();
        }

        protected void GridHistory_ItemCommand(object source, GridCommandEventArgs e)
        {
            //LoadGridApproveHistory();
        }

        protected void GridInformHis_ItemCommand(object source, GridCommandEventArgs e)
        {
            //LoadGridInformHistory();
        }

        protected void GridInform_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridInform();
        }

        protected void GridRequest_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridRequest();
        }

        protected void GridRequest_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                GridDataItem dataBoundItem = e.Item as GridDataItem;
                Control target = e.Item.FindControl("lkName");
                Control targetRefNo = e.Item.FindControl("lkRefNo");
                if (!Object.Equals(target, null))
                {
                    if (!Object.Equals(this.TipApproveDetail, null))
                    {
                        this.TipApproveDetail.TargetControls.Add(target.ClientID, "Item:" + dataBoundItem["Ref_no"].Text + ":prr", true);
                        this.TipApproveDetail.TargetControls.Add(targetRefNo.ClientID, "Item:" + dataBoundItem["Ref_no"].Text + ":prr", true);
                    }
                }
            }
        }

        protected void GridPublishing_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridPublishing();
        }

        protected void GridPublishing_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                GridDataItem dataBoundItem = e.Item as GridDataItem;
                Control target = e.Item.FindControl("lkName");
                Control targetRefNo = e.Item.FindControl("lkRefNo");
                if (!Object.Equals(target, null))
                {
                    if (!Object.Equals(this.TipApproveDetail, null))
                    {
                        this.TipApproveDetail.TargetControls.Add(target.ClientID, "Item:" + dataBoundItem["Ref_no"].Text + ":br", true);
                        this.TipApproveDetail.TargetControls.Add(targetRefNo.ClientID, "Item:" + dataBoundItem["Ref_no"].Text + ":br", true);
                    }
                }
            }
        }

        protected void OnAjaxUpdate_AppDet(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip_AppDet(args.Value, args.UpdatePanel);
        }

        private void UpdateToolTip_AppDet(string elementID, UpdatePanel panel)
        {
            string[] all_value = elementID.Split(new string[] { ":" }, StringSplitOptions.None);
            //if (all_value[0] == "Item")
            //{
            //    Session["Resource_Item_Id"] = all_value[1];
            //    Session["Expense_Id"] = null;
            //}
            //else
            //{
            //    Session["Resource_Item_Id"] = null;
            //    Session["Expense_Id"] = all_value[1];
            //}
            Session["RefNo"] = all_value[1];
            Session["DisType"] = all_value[2];
            Control ctrl = Page.LoadControl("../UserControl/TIP_Approve_Detail.ascx");
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }

        protected void OnAjaxUpdate_TipHistoryApprove(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip_TipHistoryApprove(args.Value, args.UpdatePanel);
        }

        private void UpdateToolTip_TipHistoryApprove(string elementID, UpdatePanel panel)
        {
            string[] all_value = elementID.Split(new string[] { ":" }, StringSplitOptions.None);
            Session["HisSeq"] = all_value[1];
            Control ctrl;
            if (all_value[0] == "HisApprove")
            {
                ctrl = Page.LoadControl("../UserControl/ICM_PPR_RouteHistoryApprove.ascx");
            }
            else
            {
                ctrl = Page.LoadControl("../UserControl/ICM_PPR_RouteHistoryInform.ascx");
            }
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }

        protected void OnAjaxUpdate_TipHistoryInform(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip_TipHistoryInform(args.Value, args.UpdatePanel);
        }

        private void UpdateToolTip_TipHistoryInform(string elementID, UpdatePanel panel)
        {
            string[] all_value = elementID.Split(new string[] { ":" }, StringSplitOptions.None);
            Session["HisSeq"] = all_value[1];
            Control ctrl;
            if (all_value[0] == "HisApprove")
            {
                ctrl = Page.LoadControl("../UserControl/ICM_PPR_RouteHistoryApprove.ascx");
            }
            else
            {
                ctrl = Page.LoadControl("../UserControl/ICM_PPR_RouteHistoryInform.ascx");
            }
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }

        #endregion

        //-----------------------------------------------------------------------------------------------
    }
}
